#include <stdio.h>
#include <unistd.h>

#include "ohos_init.h"
#include "cmsis_os2.h"

#include "gd32h7xx.h"
#include "systick.h"
#include "gd32h759i_eval.h"

#define THREAD_DELAY_1S 1000000

void test(void)
{

    gd_eval_led_init(LED1);
    gd_eval_led_init(LED2);
    while(1)
    { 
       printf("GpioTask: LED\n");
       gd_eval_led_toggle(LED1);
       gd_eval_led_toggle(LED2);
       //usleep(THREAD_DELAY_1S);

       //GD32H759IMT6的bsp提供的延时函数
       delay_us(1000*1000*2);
       delay_ms(1000);
    }

}

static void testTask(void)
{
    osThreadAttr_t attr;

    attr.name = "led_test";
    attr.attr_bits = 0U;
    attr.cb_mem = NULL;
    attr.cb_size = 0U;
    attr.stack_mem = NULL;
    attr.stack_size = 20*1024;
    attr.priority = osPriorityNormal;

    if (osThreadNew((osThreadFunc_t)test, NULL, &attr) == NULL) {
        printf("[testTask] Falied to create Task!\n");
    }
}
APP_FEATURE_INIT(testTask);